<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <h1><?php echo $heading_title; ?></h1>
  <table class="list">
    <thead>
      <tr>
        <td class="left" colspan="2"><?php echo $text_order_detail; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="left" style="width: 50%;"><?php if ($invoice_no) { ?>
          <b><?php echo $text_invoice_no; ?></b> <?php echo $invoice_no; ?><br />
          <?php } ?>
          <b><?php echo $text_order_id; ?></b> #<?php echo $order_id; ?><br />
          <b><?php echo $text_date_added; ?></b> <?php echo $date_added; ?></td>
        <td class="left" style="width: 50%;"><?php if ($payment_method) { ?>
          <b><?php echo $text_payment_method; ?></b> <?php echo $payment_method; ?><br />
          <?php } ?>
          <?php if ($shipping_method) { ?>
          <b><?php echo $text_shipping_method; ?></b> <?php echo $shipping_method; ?>
          <?php } ?></td>
      </tr>
    </tbody>
  </table>
  <table class="list">
    <thead>
      <tr>
        <td class="left"><?php echo $text_payment_address; ?></td>
        <?php if ($shipping_address) { ?>
        <td class="left"><?php echo $text_shipping_address; ?></td>
        <?php } ?>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="left"><?php echo $payment_address; ?></td>
        <?php if ($shipping_address) { ?>
        <td class="left"><?php echo $shipping_address; ?></td>
        <?php } ?>
      </tr>
    </tbody>
  </table>
  <table class="list">
    <thead>
      <tr>
        <td class="left"><?php echo $column_name; ?></td>
        <td class="left"><?php echo $column_model; ?></td>
        <td class="right"><?php echo $column_quantity; ?></td>
        <td class="right"><?php echo $column_price; ?></td>
        <td class="right"><?php echo $column_total; ?></td>
        <?php if ($products) { ?>
        <td style="width: 1px;"></td>
        <?php } ?>
      </tr>
    </thead>
    <tbody>
      <?php foreach ($products as $product) { ?>
      <tr>
        <td class="left"><?php echo $product['name']; ?>
          <?php foreach ($product['option'] as $option) { ?>
          <br />
          &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
          <?php } ?></td>
        <td class="left"><?php echo $product['model']; ?></td>
        <td class="right"><?php echo $product['quantity']; ?></td>
        <td class="right"><?php echo $product['price']; ?></td>
        <td class="right"><?php echo $product['total']; ?></td>
        <td class="right"><a href="<?php echo $product['return']; ?>"><img src="catalog/view/theme/default/image/return.png" alt="<?php echo $button_return; ?>" title="<?php echo $button_return; ?>" /></a></td>
      </tr>
      <?php } ?>
      <?php foreach ($vouchers as $voucher) { ?>
      <tr>
        <td class="left"><?php echo $voucher['description']; ?></td>
        <td class="left"></td>
        <td class="right">1</td>
        <td class="right"><?php echo $voucher['amount']; ?></td>
        <td class="right"><?php echo $voucher['amount']; ?></td>
        <?php if ($products) { ?>
        <td></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </tbody>
    <tfoot>
      <?php foreach ($totals as $total) { ?>
      <tr>
        <td colspan="3"></td>
        <td class="right"><b><?php echo $total['title']; ?>:</b></td>
        <td class="right"><?php echo $total['text']; ?></td>
        <?php if ($products) { ?>
        <td></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </tfoot>
  </table>
  <?php if ($comment) { ?>
  <table class="list">
    <thead>
      <tr>
        <td class="left"><?php echo $text_comment; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="left"><?php echo $comment; ?></td>
      </tr>
    </tbody>
  </table>
  <?php } ?>
  <?php if ($histories) { ?>
  <h2><?php echo $text_history; ?></h2>
  <table class="list">
    <thead>
      <tr>
        <td class="left"><?php echo $column_date_added; ?></td>
        <td class="left"><?php echo $column_status; ?></td>
        <td class="left"><?php echo $column_comment; ?></td>
      </tr>
    </thead>
    <tbody>
      <?php foreach ($histories as $history) { ?>
      <tr>
        <td class="left"><?php echo $history['date_added']; ?></td>
        <td class="left"><?php echo $history['status']; ?></td>
        <td class="left"><?php echo $history['comment']; ?></td>
      </tr>
      <?php } ?>
    </tbody>
  </table>
  <?php } ?>
  <?php if ($order_express_number) { ?>
  <h2>快递信息</h2>
  <table class="list">
    <thead>
      <tr>
        <td class="left">快递公司</td>
        <td class="left">快递单号</td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="left"><?php echo $order_express_name; ?></td>
        <td class="left"><?php echo $order_express_number; ?></td>
      </tr>
    </tbody>
  </table>
  <h2>快递跟踪(<span style="color:#888888;font-size:12px;">数据由<a style="color:#d00;" href='http://www.kuaidi100.com' target="_blank">快递100</a>提供<span>)</h2>
  <table class="list">
    <thead>
      <tr>
        <td class="left">时间</td>
        <td class="left">地点和跟踪进度</td>
      </tr>
    </thead>
    <tbody id="track_list">
    </tbody>
  </table>
  <div class="buttons">
    <div class="right"><a href="<?php echo $continue; ?>" class="button"><?php echo $button_continue; ?></a></div>
  </div>
  <script type="text/javascript">
	function express_track(){
		var url="http://www.kuaidi100.com/query?type=<?php echo $order_express_code; ?>&postid=<?php echo $order_express_number; ?>&id=1&temp="+Math.random();
	    $.ajax({
	        url: url,
	        dataType: "jsonp",
	        jsonp: "callback",
	        beforeSend: function() {
	            $('#track_list').html("");
	        	$('#track_list').append('<tr><td class="left" colspan="2"><img src="catalog/view/theme/moderns/image/progress.gif" width="12"  alt="" /> 数据加载中...</td></tr>');
	        },
	        success: function (json) {
	            $('#track_list').html("");
	            var html='';
		        if(json.message=='ok'){
			         $.each(json.data,function(index,entry){
			              html += '<tr>';
					      html += '<td class="left">'+entry['time']+'</td>';
					      html += '<td class="left">'+entry['context']+'</td>';
					      html += '</tr>';
					 });  
		        }else{
		            html += '<tr>';
					html += '<td class="left" colspan="2">暂无跟踪信息</td>';
					html += '</tr>';
		        }
		        $('#track_list').append(html);
	        },
	        error: function(){
	            $('#track_list').html("");
	        	var html = '<tr>';
					html += '<td class="left" colspan="2">数据请求失败，请 <a href="javascript:void(0);" onclick="javascript:express_track();"  style="color:#d00;">刷新</a> 重试</td>';
					html += '</tr>';
				$('#track_list').append(html);
	        }
	    });
	}
	
	$(document).ready(function() {
	     express_track();
	});
	</script>
  <?php } ?>
  <?php echo $content_bottom; ?></div>
<?php echo $footer; ?> 